package com.hdoit.kylin.web.door.controllers;


import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.hdoit.kylin.logical.group.model.Group;
import com.hdoit.kylin.logical.group.service.IGroupService;
import com.hdoit.kylin.logical.group.service.IProjectService;
import com.hdoit.kylin.logical.user.model.Student;
import com.hdoit.kylin.logical.user.model.Teacher;
import com.hdoit.kylin.logical.user.service.IStudentService;
import com.hdoit.kylin.logical.user.service.ITeacherService;
import com.tennetcn.web.cbase.AuthPassport;
import com.tennetcn.web.home.controllers.BaseHomeController;
/** 
 * @author      chenghuan
 * @email       79763939@qq.com
 * @createtime  2016年4月14日
 * @comment 
 */
@Controller
@RequestMapping(value = "/admin/door/")
public class DoorControllers extends BaseHomeController{
	@Override
	public String getRoutePath() {
		return "areas/admin/door/";
	}	
	
	private IGroupService groupService;
	private IProjectService projectService;
	private ITeacherService teacherService;
	private IStudentService studentService;

	public ITeacherService getTeacherService() {
		return teacherService;
	}

	@Resource
	public void setTeacherService(ITeacherService teacherService) {
		this.teacherService = teacherService;
	}

	public IProjectService getProjectService() {
		return projectService;
	}

	@Resource
	public void setProjectService(IProjectService projectService) {
		this.projectService = projectService;
	}

	public IGroupService getGroupService() {
		return groupService;
	}

	@Resource
	public void setGroupService(IGroupService groupService) {
		this.groupService = groupService;
	}
	
	private final String homeViewName="home";


	@AuthPassport
	@RequestMapping(value=homeViewName,method={RequestMethod.GET,RequestMethod.POST})
	public String index(Model model,String key){
		
		Group group=groupService.queryModel(key);

		List<Teacher> teachers = teacherService.queryListByGroupId(null,null,key);
		List<Student> students = studentService.queryListByGroupId(null,null,key);

		
//		File file = new File("address");
//		String[] fileName = file.list();
//		List<String> fileNames = null;
//		if(null!=fileName){
//			fileNames = Arrays.asList(fileName);
//		}
		model.addAttribute("group",group);
		model.addAttribute("teachers",teachers);
		model.addAttribute("students",students);
//		model.addAttribute("fileNames", fileNames);
		
		return view(homeViewName);
	}

	public IStudentService getStudentService() {
		return studentService;
	}

	@Resource
	public void setStudentService(IStudentService studentService) {
		this.studentService = studentService;
	}
}
